package smoothcraft.cn.shop.GUI.InventoryContent;

import java.util.ArrayList;
import java.util.UUID;

import org.bukkit.entity.Player;

import fr.minuskube.inv.ClickableItem;
import fr.minuskube.inv.content.InventoryContents;
import fr.minuskube.inv.content.InventoryProvider;
import fr.minuskube.inv.content.Pagination;
import fr.minuskube.inv.content.SlotIterator;
import smoothcraft.cn.shop.Shop_API;
import smoothcraft.cn.shop.GUI.Inv_gui;
import smoothcraft.cn.shop.data.Shop;

public class VisitShop_page implements InventoryProvider{

	@Override
	public void init(Player p, InventoryContents inv) {
		Pagination page = inv.pagination();
		ArrayList<Shop> shop = Shop_API.yaml.getShops();
		ClickableItem click[] = new ClickableItem[shop.size()];
		for(int x = 0,size = click.length;x<size;x++) {
			UUID uuid = shop.get(x).getID();
			click[x] = ClickableItem.of(shop.get(x).getIcon(), e -> {
				Inv_gui.inv_shop.get(uuid).open(p);
			});
		}
		page.setItems(click);
		page.setItemsPerPage(27);
		page.addToIterator(inv.newIterator(SlotIterator.Type.HORIZONTAL,0,0));
	}

	@Override
	public void update(Player p, InventoryContents inv) {}

}
